Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting different namespace root #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

shioyama
Copy link
Owner

@shioyama shioyama commented May 15, 2023

Currently the root for any loaded namespace is the loader instance. But someone may want to set autoloads on another (named or anonymous) module, and there is no reason Im should not support this.

With this change, it is now possible to pass a root when initializing a loader. This root (a module) is then used in place of the loader itself as the root of the (auto)loaded namespace.

e.g.

mod = Module.new
loader = Im::Loader.new(root: mod)
loader.push_dir(...)
loader.setup

Now, autoloads are set on mod instead of loader. Passing Object as root here makes Im act like Zeitwerk.

Currently the root for any loaded namespace is the loader instance. But
someone may want to set autoloads on a nother (named or anonymous)
module, and there is no reason Im should not support this.

With this change, it is now possible to pass a "root" when initializing
a loader. This root (a module) is then used in place of the loader
itself as the root of the (auto)loaded namespace.
@shioyama
Copy link
Owner Author

I need to update the readme and add changelog entry etc, but otherwise this should be a simple change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant